﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using StampController.BL.Models;
using StampController.BL;

namespace StampController.Pages
{
    public partial class FeedbackList : System.Web.UI.Page
    {
        protected void Page_Load(object seander, EventArgs e)
        {
            if (!IsPostBack)
            {
                var user = SessionUtils.Get<UsersModel>("USER");
                if (user == null)
                    Response.Redirect("/");
            }
        }

        private const int PageSize = 20;

        [WebMethod]
        public static object GetFeedbackList(int pageNum)
        {
            //var user = SessionUtils.Get<UsersModel>("USER");

            int count;
            var im = new FeedbackFormImpl();
            IList<FeedbackModel> list = im.GetFeedbackList(pageNum, PageSize, out count);
            var obj = new GridTable<FeedbackModel>
            {
                PageNum = pageNum,
                RowCount = count,
                PageSize = PageSize,
                List = list,
            };

            return obj;
        }

        //[WebMethod]
        //public static bool DeleteItem(string id)
        //{
        //    var user = SessionUtils.Get<UsersModel>("USER");
        //    if (user == null)
        //    {
        //        return false;
        //    }
        //    var im = new FeedbackFormImpl();
        //    return im.SaveFeedback(new FeedbackModel
        //    {
        //        ID = new Guid(id),
        //        ModifiedDate = DateTime.Now,
        //        ModifiedBy = user.UserID,
        //        Active = false
        //    });
        //}
    }
}